﻿using System.Data;

namespace DAL
{
    public static class DalRecruitmentPlanMainDetail
    {
        private static readonly clsConnect Cls = new clsConnect();
        #region[Get-Data]
        public static DataTable GetRecruitmentPlanMainDetail(int ID_Main)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID_Main", ID_Main);
            return Cls.GetData("sp_Recruitment_Plan_Main_Detail_Get");
        }
        public static DataTable GetRecruitmentPlanMainDetailTemp(int Users_Id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Users_Id", Users_Id);
            return Cls.GetData("sp_Recruitment_Plan_Main_Detail_GetTemp");
        }
        public static DataTable GetRecruitmentPlanMainDetailEdit(int id)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID_Main_Detail", id);
            return Cls.GetData("sp_Recruitment_Plan_Main_Detail_Get_Edit");
        }
        #endregion

        #region[Insert-Update-Delete]
        public static bool Insert(EtRecruitmentPlanMainDetail obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Level_Main", obj.Level_Main);
            Cls.AddParameter("@ID_Main", obj.ID_Main);
            Cls.AddParameter("@Office", obj.Office);
            Cls.AddParameter("@Quanlity", obj.Quanlity);
            Cls.AddParameter("@TimeLine", obj.TimeLine);
            Cls.AddParameter("@Plan_Name", obj.Plan_Name);
            Cls.AddParameter("@Users_Id", obj.Users_Id);
            Cls.AddParameter("@Flag", obj.Flag);
            return Cls.ExecuteNonQuery("sp_Recruitment_Plan_Main_Detail_Insert");
        }
        public static bool Update(EtRecruitmentPlanMainDetail obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID_Main_Detail", obj.ID_Main_Detail);
            Cls.AddParameter("@ID_Main", obj.ID_Main);
            Cls.AddParameter("@Level_Main", obj.Level_Main);
            Cls.AddParameter("@Office", obj.Office);
            Cls.AddParameter("@Quanlity", obj.Quanlity);
            Cls.AddParameter("@TimeLine", obj.TimeLine);
            Cls.AddParameter("@Plan_Name", obj.Plan_Name);
            Cls.AddParameter("@Users_Id", obj.Users_Id);
            Cls.AddParameter("@Flag", obj.Flag);
            return Cls.ExecuteNonQuery("sp_Recruitment_Plan_Main_Detail_Update");
        }
        public static bool Delete(EtRecruitmentPlanMainDetail obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@ID_Main_Detail", obj.ID_Main_Detail);
            return Cls.ExecuteNonQuery("sp_Recruitment_Plan_Main_Detail_Delete");
        }
        public static bool DeleteTemp(EtRecruitmentPlanMainDetail obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Users_Id ", obj.Users_Id);
            return Cls.ExecuteNonQuery("sp_Recruitment_Plan_Main_Detail_DeleteTemp");
        }
        public static bool InsertPlanName(EtRecruitmentPlanMainDetail obj)
        {
            Cls.CreateNewSqlCommand();
            Cls.AddParameter("@Main_Code", obj.Plan_Name);
            Cls.AddParameter("@Main_Name", obj.Users_Id);
            Cls.AddParameter("@Datebegin", obj.Flag);
            return Cls.ExecuteNonQuery("sp_Recruitment_Plan_Main_Detail_Insert_Plan_Name");
        }
        #endregion
    }
    public class EtRecruitmentPlanMainDetail
    {
        public int ID_Main_Detail { get; set; }
        public int ? ID_Main { get; set; }
        public string Level_Main { get; set; }
        public string Office { get; set; }
        public int ? Quanlity { get; set; }
        public string TimeLine { get; set; }
        public string Plan_Name { get; set; }
        public int ? Users_Id { get; set; }
        public int ? Flag { get; set; }
    }
}